package model

import (
	"gorm.io/gorm"
	"time"
)

//UserInfo 用户信息模型
type UserInfo struct {
	Uid       string    `json:"uid"`
	Username  string    `json:"username"`
	Name      string    `json:"name"`
	Age       int8      `json:"age"`
	Sex       uint8     `json:"sex"`
	Email     string    `json:"email"`
	Introduce string    `json:"introduce"`
	Country   string    `json:"country"`
	Address   string    `json:"address"`
	Github    string    `json:"github"`
	CreateAt  time.Time `json:"create_at"`
	UpdateAt  time.Time `json:"update_at"`
}

func (u UserInfo)TableName()string{
	return "user_info"
}

func (u *UserInfo) BeforeCreate(tx *gorm.DB) error {
	u.CreateAt = time.Now()
	u.UpdateAt = time.Now()
	return nil
}

func (u *UserInfo) BeforeUpdate(tx *gorm.DB) error {
	u.UpdateAt = time.Now()
	return nil
}